import request from '@/utils/defaultRequest'

// 获取猜你喜欢列表
export function getLikeList(pageNo, pageSize) {
   if (pageNo) {
      return request({
         url: `/like?pageNo=${pageNo}&pageSize=${pageSize}`,
         method: 'get'
      })
   } else {
      return request({
         url: '/like',
         method: 'get'
      })
   }
}
// 添加或者修改猜你喜欢
export function addOrUpdate(data) {
   if (data.id || data.id == 0) { //修改
      return request({
         url: `/product/editLikeList/${data.id}`,
         method: 'post',
         data: data.data
      })
   } else { // 添加
      return request({
         url: '/product/addLikeList',
         method: 'post',
         data: data.data
      })
   }
}

// 根据id删除喜欢/api/product/deltLikeList/:id
export function deltLikeList(id) {
   return request({
      url: `/product/deltLikeList/${id}`,
      method: 'post'
   })
}

// 根据id查询喜欢/api/product/getOneLike/:id
export function getOneLike(shopName) {
   return request({
      url: `/product/getOneLike/${shopName}`,
      method: 'post'
   })
}

// 根据猜你喜欢id添加详情/api/product/addLikeDetail/:id
export function addLikeDetail(data) {
   return request({
      url: `/product/addLikeDetail/${data.id}`,
      method: 'post',
      data: data.shopDetailFormData
   })
}

// 根据传入id修改猜你喜欢
export function editLikeDetail(data) {
   return request({
      url: `/product/editLikeDetail/${data.id}`,
      method: 'post',
      data: data.shopDetailFormData
   })
}

// 根据传入id获取商品详情
export function likeDetail(id) {
   return request({
      url: `/likeDetail/${id}`,
      method: 'get'
   })
}
